home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2001 Haziran / CHIP Haziran2001.iso / prog / share / 16 / setup.exe / %AppDir% / AddIns / Context Menus.ext < prev    next >
Encoding:
Text File  |  2001-04-24  |  19.0 KB  |  661 lines

  1. If you compile the menus with this AddIn, a predefined menu will be displayed when the user rightclicks over the document, instead of browser's default context menu.
  2.  
  3. NOTE: This AddIn may not work with frames support turned on.
  4.  
  5. Developed by Xavier Flix
  6. ***
  7. //COPYRIGHT
  8.     
  9.     var nStyle = new Array;
  10.     var hStyle = new Array;
  11.     var nLayer = new Array;
  12.     var hLayer = new Array;
  13.     var nTCode = new Array;
  14.     
  15.     var AnimStep = 0;
  16.     var AnimHnd = 0;
  17.     var HTHnd = new Array;
  18.     var DoFormsTweak = true;
  19.     
  20.     var mFrame;
  21.     var cFrame;
  22.     
  23.     var OpenMenus = new Array;
  24.     var SelCommand;
  25.     var nOM = 0;
  26.     
  27.     var mX;
  28.     var mY;
  29.     var xOff = 0;
  30.     
  31.     var HideSpeed = 300;
  32.     
  33. //BROWSERDETECTION
  34.     
  35.     if((!IsWin&&IE)||SM) {
  36.     frames.self = window;
  37.     frames.top = top;
  38.     }
  39.     
  40.     if(IE)
  41.     xOff = (SM&&!OP)?-9:2;
  42. //CODEFRAME
  43.     
  44. //FX
  45.     
  46. //STYLECODE
  47.  
  48.     function GetCurCmd(e) {
  49.         //IE
  50.         //This function will return the current command under the mouse pointer. It will return null if the mouse is not over any command.
  51.         //------------------------------
  52.         //Version 1.3
  53.         //
  54.         if(SM)
  55.             var cc = e;
  56.         else
  57.             var cc = mFrame.window.event.srcElement;
  58.         while(cc.id=="") {
  59.             cc = cc.parentElement;
  60.             if(cc==null)
  61.                 break;
  62.         }
  63.         return cc;
  64.     }
  65.  
  66.     function HoverSel(mode, imgLName, imgRName, e) {
  67.         //IE
  68.         //This is the function called every time the mouse pointer is moved over or away from a command.
  69.         //------------------------------
  70.         //mode: 0 if the mouse is moving over the command and 1 if is moving away
  71.         //imgName: Name of the image object, if any, used in the selected command
  72.         //------------------------------
  73.         //Version 8.0
  74.         //
  75.         var imgL = new Image;
  76.         var imgLRsc = new Image;
  77.         var imgR = new Image;
  78.         var imgRRsc = new Image;
  79.         var nStyle;
  80.         var mc;
  81.         
  82.         if(mode==0 && OpenMenus[nOM].SelCommand!=null)
  83.             HoverSel(1);
  84.         
  85.         if(imgLName!="_")
  86.             var imgL = eval("mFrame.document.images['"+imgLName+"']");
  87.         if(imgRName!="_")
  88.             var imgR = eval("mFrame.document.images['"+imgRName+"']");
  89.         
  90.         if(mode==0) {
  91.             mc = GetCurCmd(e);
  92.             if(nOM>1)
  93.                 if(mc==OpenMenus[nOM-1].SelCommand)
  94.                     return false;
  95.             if(OpenMenus[nOM].SelCommand || nOM>1)
  96.                 while(!InMenu()&&nOM>1)
  97.                     Hide();
  98.             if(imgLName!='_') imgLRsc = eval(imgLName+"On");
  99.             if(imgRName!='_') imgRRsc = eval(imgRName+"On");
  100.             OpenMenus[nOM].SelCommand = mc;
  101.             OpenMenus[nOM].SelCommandPar = [imgLName,imgRName,SM?mc.getAttribute("style"):mc.style.cssText];
  102.             if(SM)
  103.                 mc.setAttribute("style", GetCStyle(mc.style) + hStyle[mc.id]);
  104.             else
  105.                 mc.style.cssText = GetCStyle(mc.style) + hStyle[mc.id];
  106.         } else {
  107.             mc = (mode==1)?OpenMenus[nOM].SelCommand:OpenMenus[nOM].Opener;
  108.             imgLName = (mode==1)?OpenMenus[nOM].SelCommandPar[0]:OpenMenus[nOM].OpenerPar[0];
  109.             imgRName = (mode==1)?OpenMenus[nOM].SelCommandPar[1]:OpenMenus[nOM].OpenerPar[1];
  110.             nStyle = (mode==1)?OpenMenus[nOM].SelCommandPar[2]:OpenMenus[nOM].OpenerPar[2];
  111.             mc.style.background = "";
  112.             if(SM)
  113.                 mc.setAttribute("style", nStyle);
  114.             else
  115.                 mc.style.cssText = nStyle;
  116.             if(imgLName!='_') imgLRsc = eval(imgLName+"Off");
  117.             if(imgRName!='_') imgRRsc = eval(imgRName+"Off");
  118.             window.status = "";
  119.             OpenMenus[nOM].SelCommand = null;            
  120.         }
  121.         
  122.         if(imgLName!='_') {
  123.             imgL = eval("mFrame.document.images."+imgLName);
  124.             imgL.src = imgLRsc.src;
  125.         }
  126.         if(imgRName!='_') {
  127.             imgR = eval("mFrame.document.images."+imgRName);
  128.             imgR.src = imgRRsc.src;
  129.         }
  130.         
  131.         return true;
  132.     }
  133.  
  134.     function NSHoverSel(mode, mc, bcolor) {
  135.         //NS
  136.         //This is the function called every time the mouse pointer is moved over or away from a command.
  137.         //------------------------------
  138.         //mc: Name of the layer that corresponds to the selected command
  139.         //mode: 0 if the mouse is moving over the command and 1 if is moving away
  140.         //n: Unique ID that identifies this command. Used to retrieve the data from the nLayer or hLayer array.
  141.         //bcolor: Background color of the command. Ignored if the group uses a background image.
  142.         //w: Width of the command's layer.
  143.         //h: Height of the command's layer.
  144.         //------------------------------
  145.         //Version 10.0
  146.         //
  147.         var n;
  148.         var LayerHTM;
  149.         
  150.         window.clearTimeout(CBparseInt(HTHnd[nOM]));HTHnd[nOM] = 0;
  151.         if(!nOM) return false;
  152.         
  153.         if(mode==0 && OpenMenus[nOM].SelCommand!=null)
  154.             NSHoverSel(1);
  155.         
  156.         if(mode==0) {
  157.             mc = mc.parentLayer.layers[mc.name.substr(0, mc.name.indexOf("EH"))];
  158.             n = CBparseInt(mc.name.substr(2));
  159.             if(nOM>1)
  160.                 if(mc==OpenMenus[nOM-1].SelCommand)
  161.                     return false;
  162.             while(!InMenu()&&nOM>1)
  163.                 Hide();
  164.             LayerHTM = hLayer[n];
  165.             OpenMenus[nOM].SelCommand = mc;
  166.             OpenMenus[nOM].SelCommandPar = mc.bgColor;
  167.             mc.bgColor = bcolor;
  168.         } else {
  169.             mc = (mode==1)?OpenMenus[nOM].SelCommand:OpenMenus[nOM].Opener;
  170.             bcolor = (mode==1)?OpenMenus[nOM].SelCommandPar:OpenMenus[nOM].OpenerPar;
  171.             n = CBparseInt(mc.name.substr(2));
  172.             LayerHTM = nLayer[n];
  173.             if(mc.parentLayer.background.src!="")
  174.                 mc.bgColor = null;
  175.             else
  176.                 mc.bgColor = bcolor;
  177.             window.status = "";
  178.             OpenMenus[nOM].SelCommand = null;
  179.         }
  180.         mc.clip.width = mc.parentLayer.parentLayer.clip.width - 2*mc.parentLayer.left;
  181.         mc.document.open();
  182.         mc.document.write(LayerHTM);
  183.         mc.document.close();
  184.         
  185.         return true;
  186.     }
  187.  
  188.     function Hide() {
  189.         //IE,NS
  190.         //This function hides the group identified by the menuId parameter.
  191.         //It also resets the values of the CurMenu and ParentMenu variables to reflect the changes of the hidden menu.
  192.         //------------------------------
  193.         //menuId: Name of the group's <div> or <layer> to be hidden.
  194.         //------------------------------
  195.         //Version 2.1
  196.         //
  197.         window.clearTimeout(HTHnd[nOM]);HTHnd[nOM] = 0;
  198.         window.clearTimeout(AnimHnd);AnimHnd = 0;
  199.         
  200.         if(OpenMenus[nOM].SelCommand!=null) {
  201.             if(IE) HoverSel(1);
  202.             if(NS) NSHoverSel(1);
  203.         }
  204.         if(OpenMenus[nOM].Opener!=null) {
  205.             if(IE) HoverSel(3);
  206.             if(NS) NSHoverSel(3);
  207.         }
  208.         
  209.         OpenMenus[nOM].visibility = "hidden";
  210.         nOM--;
  211.         
  212.         if(nOM>0)
  213.             if(!InMenu())
  214.                 HTHnd[nOM] = window.setTimeout("Hide()", HideSpeed/4);
  215.         
  216.         if(nOM==0)
  217.             FormsTweak("visible");
  218.     }
  219.  
  220.     function ShowMenu(mName, x, y, isCascading) {
  221.         //IE,NS
  222.         //This is the main function to show the menus when a hotspot is triggered or a cascading command is activated.
  223.         //------------------------------
  224.         //menuId: Name of the <div> or <layer> to be shown.
  225.         //x: Left position of the menu.
  226.         //y: Top position of the menu.
  227.         //isCascading: True if the menu has been triggered from a command, and not from a hotspot.
  228.         //------------------------------
  229.         //Version 12.9
  230.         //        
  231.         //(as) {
  232.         //indow.clearTimeout(as);
  233.         //s = 0;
  234.         //
  235.         window.clearTimeout(CBparseInt(HTHnd[nOM]));HTHnd[nOM] = 0;
  236.         x = CBparseInt(x);y = CBparseInt(y);
  237.         
  238.         if(AnimHnd && nOM>0) {
  239.             AnimStep=101;
  240.             Animate();
  241.         }
  242.         if(IE)
  243.             if(SM)
  244.                 var Menu = mFrame.document.getElementById(mName);
  245.             else
  246.                 var Menu = mFrame.document.all[mName];
  247.         if(NS)
  248.             var Menu = mFrame.document.layers[mName];
  249.         if(!Menu)
  250.             return false;
  251.         if(IE)
  252.             Menu = Menu.style;
  253.         if(Menu==OpenMenus[nOM])
  254.             return false;
  255.             
  256.         if(!isCascading)
  257.             HideAll();
  258.             
  259.         Menu.Opener = nOM>0?OpenMenus[nOM].SelCommand:null;
  260.         Menu.OpenerPar = nOM>0?OpenMenus[nOM].SelCommandPar:null;
  261.         Menu.SelCommand = null;
  262.         if(OP) {
  263.             Menu.width = Menu.pixelWidth;
  264.             Menu.height = Menu.pixelHeight;
  265.         }
  266.         
  267.         var pW = GetWidthHeight()[0] + GetLeftTop()[0];
  268.         var pH = GetWidthHeight()[1] + GetLeftTop()[1];
  269.         
  270.         if(IE) {
  271.             if(isCascading) {
  272.                 x = CBparseInt(OpenMenus[nOM].left) + CBparseInt(OpenMenus[nOM].width) - 6;
  273.                 y = CBparseInt(OpenMenus[nOM].SelCommand.style.top) + CBparseInt(OpenMenus[nOM].top) - y;
  274.                 Menu.left = (x+CBparseInt(Menu.width)>pW)?CBparseInt(OpenMenus[nOM].left) - CBparseInt(Menu.width) + 6:x;
  275.                 Menu.top =  (y+CBparseInt(Menu.height)>pH)?pH - CBparseInt(Menu.height):y;
  276.             } else {
  277.                 Menu.left = (x+CBparseInt(Menu.width)>pW)?pW - CBparseInt(Menu.width):x;
  278.                 Menu.top =  (y+CBparseInt(Menu.height)>pH)?pH - CBparseInt(Menu.height):y;
  279.             }
  280.             if(IsWin&&!SM)
  281.                 Menu.clip = "rect(0 0 0 0)";
  282.         }
  283.         if(NS) {
  284.             if(isCascading) {
  285.                 x = OpenMenus[nOM].left + OpenMenus[nOM].clip.width - 6;
  286.                 y = OpenMenus[nOM].top + OpenMenus[nOM].SelCommand.top;
  287.                 x = (x+Menu.w>pW)?OpenMenus[nOM].left - Menu.w + 6:x;
  288.                 y = (y+Menu.h>pH)?pH - Menu.h:y;
  289.             } else {
  290.                 x = (x+Menu.w>pW)?pW - Menu.w:x;
  291.                 y = (y+Menu.h>pH)?pH - Menu.h:y;
  292.             }
  293.             Menu.clip.width = 0;
  294.             Menu.clip.height = 0;
  295.             Menu.moveToAbsolute(x,y);
  296.         }
  297.         if(isCascading)
  298.             Menu.zIndex = CBparseInt(OpenMenus[nOM].zIndex) + 1;
  299.         Menu.visibility = "visible";
  300.         OpenMenus[++nOM] = Menu;
  301.         HTHnd[nOM] = 0;
  302.         if((IE&&IsWin&&!SM)||NS)
  303.             AnimHnd = window.setTimeout("Animate()", 10);
  304.         FormsTweak("hidden");
  305.         
  306.         return true;
  307.     }
  308.  
  309.     function Animate() {
  310.         //IE,NS
  311.         //This function is called by ShowMenu every time a new group must be displayed and produces the predefined unfolding effect.
  312.         //Currently is disabled for Navigator, because of some weird bugs we found with the clip property of the layers.
  313.         //------------------------------
  314.         //menuId: Name of the <div> or <layer> to be animated.
  315.         //------------------------------
  316.         //Version 1.3
  317.         //
  318.         var r = '';
  319.         var nw = nh = 0;
  320.         switch(fx) {
  321.             case 1:
  322.                 if(IE) r = "0 " + AnimStep + "% " + AnimStep + "% 0";
  323.                 if(NS) nw = AnimStep; nh = AnimStep;
  324.                 break;
  325.             case 2:
  326.                 if(IE) r = "0 100% " + AnimStep + "% 0";
  327.                 if(NS) nw = 100; nh = AnimStep;
  328.                 break;
  329.             case 3:
  330.                 if(IE) r = "0 " + AnimStep + "% 100% 0";
  331.                 if(NS) nw = AnimStep; nh = 100;
  332.                 break;
  333.             case 0:
  334.                 if(IE) r = "0 100% 100% 0";
  335.                 if(NS) nw = 100; nh = 100;
  336.                 break;
  337.         }
  338.         if(OpenMenus[nOM]) {
  339.             with(OpenMenus[nOM]) {
  340.                 if(IE)
  341.                     clip =  "rect(" + r + ")";
  342.                 if(NS) {
  343.                     clip.width = w*(nw/100);
  344.                     clip.height = h*(nh/100);
  345.                 }
  346.             }
  347.             AnimStep += 20;
  348.             if(AnimStep<=100)
  349.                 AnimHnd = window.setTimeout("Animate()",25);
  350.             else {
  351.                 window.clearTimeout(AnimHnd);
  352.                 AnimStep = 0;
  353.                 AnimHnd = 0;
  354.             }
  355.         }
  356.     }
  357.  
  358.     function InMenu() {
  359.         //IE,NS
  360.         //This function returns true if the mouse pointer is over a group.
  361.         //------------------------------
  362.         //mX: Current X position of the mouse pointer.
  363.         //mY: Current Y position of the mouse pointer.
  364.         //m: <div> or <layer> object to be tested.
  365.         //------------------------------
  366.         //Version 1.2
  367.         //
  368.         var m = OpenMenus[nOM];
  369.         if(!m)
  370.             return false;
  371.         if(IE&&!SM)
  372.             SetPointerPos();            
  373.         var l = CBparseInt(m.left) + xOff;
  374.         var r = l+(IE?CBparseInt(m.width):m.clip.width) - xOff;
  375.         var t = CBparseInt(m.top) + xOff;
  376.         var b = t+(IE?CBparseInt(m.height):m.clip.height) - xOff;
  377.         return ((mX>=l && mX<=r) && (mY>=t && mY<=b));
  378.     }
  379.  
  380.     function SetPointerPos(e) {
  381.         //IE,NS
  382.         //This function sets the mX and mY variables with the current position of the mouse pointer.
  383.         //------------------------------
  384.         //e: Only used under Navigator, corresponds to the Event object.
  385.         //------------------------------
  386.         //Version 1.0
  387.         //
  388.         if(IE) {
  389.             if(!SM) {
  390.                 if(mFrame!=cFrame||event==null)
  391.                     if(mFrame.window.event==null)
  392.                         return;
  393.                     else
  394.                         e = mFrame.window.event;
  395.                 else
  396.                     e = event;
  397.             }
  398.             mX = e.clientX + GetLeftTop()[0];
  399.             mY = e.clientY + GetLeftTop()[1];
  400.         }
  401.         if(NS) {
  402.             mX = e.pageX;
  403.             mY = e.pageY;
  404.         }
  405.     }
  406.  
  407.     function HideMenus(e) {
  408.         //IE,NS
  409.         //This function checks if the mouse pointer is on a valid position and if the current menu should be kept visible.
  410.         //The function is called every time the mouse pointer is moved over the document area.
  411.         //------------------------------
  412.         //e: Only used under Navigator, corresponds to the Event object.
  413.         //------------------------------
  414.         //Version 25.0
  415.         //
  416.         if(nOM>0) {
  417.             SetPointerPos(e);
  418.             if(OpenMenus[nOM].SelCommand!=null)
  419.                 if(!InMenu()&&!HTHnd[nOM])
  420.                     HTHnd[nOM] = window.setTimeout("if(nOM>0)if(!InMenu())Hide()", HideSpeed);
  421.         }
  422.     }
  423.  
  424.     function FormsTweak(state) {
  425.         //IE
  426.         //This is an undocumented function, which can be used to hide every form element on a page.
  427.         //This can be useful if the menus will be displayed over an area where is a combo box, which is an element that cannot be placed behind the menus and it will always appear over the menus resulting in a very undesirable effect.
  428.         //------------------------------
  429.         //Version 1.0
  430.         //
  431.         if(DoFormsTweak && IE)
  432.             for(var f = 0; f <= (mFrame.document.forms.length - 1); f++)
  433.                 for(var e = 0; e <= (mFrame.document.forms[f].elements.length - 1); e++)
  434.                     if(mFrame.document.forms[f].elements[e].type=="select-one")
  435.                         mFrame.document.forms[f].elements[e].style.visibility = state;
  436.     }
  437.  
  438.     function execURL(url, tframe) {
  439.         //IE,NS
  440.         //This function is called every time a command is triggered to jump to another page or execute some javascript code.
  441.         //------------------------------
  442.         //url: Encrypted URL that must be opened or executed.
  443.         //tframe: If the url is a document location, tframe is the target frame where this document will be opened.
  444.         //------------------------------
  445.         //Version 1.0
  446.         //
  447.         HideAll();
  448.         window.setTimeout("execURL2('" + url + "', '" + tframe + "')", 100);
  449.     }
  450.  
  451.     function execURL2(url, tframe) {
  452.         //IE,NS
  453.         //This function is called every time a command is triggered to jump to another page or execute some javascript code.
  454.         //------------------------------
  455.         //url: Encrypted URL that must be opened or executed.
  456.         //tframe: If the url is a document location, tframe is the target frame where this document will be opened.
  457.         //------------------------------
  458.         //Version 1.0
  459.         //
  460.         var fObj = eval(rStr(tframe));
  461.         url = rStr(url);
  462.         url.indexOf("javascript")!=url.indexOf("vbscript")?eval(url):fObj.location.href = url;
  463.     }
  464.  
  465.     function rStr(s) {
  466.         //IE,NS
  467.         //This function is used to decrypt the URL parameter from the triggered command.
  468.         //------------------------------
  469.         //Version 1.1
  470.         //
  471.         s = xrep(s,"\x1E","'");
  472.         s = xrep(s,"\x1D","\x22");
  473.         s = xrep(s,"\x1C",",");
  474.         return s;
  475.     }
  476.  
  477.     function xrep(s, f, n) {
  478.         //IE,NS
  479.         //This function looks for any occurrence of the f string and replaces it with the n string.
  480.         //------------------------------
  481.         //Version 1.0
  482.         //
  483.         var tmp = s.split(f);
  484.         return tmp.join(n);
  485.     }
  486.  
  487.     function hNSCClick(e) {
  488.         //NS
  489.         //This function executes the selected command's trigger code.
  490.         //------------------------------
  491.         //Version 1.0
  492.         //
  493.         eval(this.TCode);
  494.     }
  495.  
  496.     function CBparseInt(n) {
  497.         //NS
  498.         //his function fixes a bug in Navigator's parseInt() function for the Mac.
  499.         //-----------------------------
  500.         //ersion 1.0
  501.         //
  502.         if(typeof(n)=="number"||typeof(n)=="string")
  503.             return (!IsWin&&!SM?n:parseInt(n))*1;
  504.         return 0;
  505.     }
  506.  
  507.     function HideAll() {
  508.         //IE,NS
  509.         //This function will hide all the currently opened menus.
  510.         //------------------------------
  511.         //Version 1.0
  512.         //
  513.         while(nOM>0)
  514.             Hide();
  515.     }
  516.  
  517.     function GetLeftTop() {
  518.         //IE,NS
  519.         //This function returns the scroll bars position on the menus frame.
  520.         //------------------------------
  521.         //Version 1.0
  522.         //
  523.         if(IE)
  524.             return [OP?0:SM?mFrame.scrollX:mFrame.document.body.scrollLeft,OP?0:SM?mFrame.scrollY:mFrame.document.body.scrollTop];
  525.         if(NS)
  526.             return [mFrame.pageXOffset,mFrame.pageYOffset];
  527.     }
  528.  
  529.     function tHideAll() {
  530.         //IE,NS
  531.         //This function is called when the mouse is moved away from a hotspot to close any opened menu.
  532.         //------------------------------
  533.         //Version 1.0
  534.         //
  535.         HTHnd[nOM] = window.setTimeout("if(!InMenu()&&nOM==1)HideAll(); else HTHnd[nOM]=0;", HideSpeed);
  536.     }
  537.  
  538.     function GetWidthHeight() {
  539.         //IE,NS
  540.         //This function returns the width and height of the menus frame.
  541.         //------------------------------
  542.         //Version 1.0
  543.         //
  544.         if(IE&&!SM)
  545.             return [mFrame.document.body.clientWidth,mFrame.document.body.clientHeight];
  546.         if(NS||SM)
  547.             return [mFrame.innerWidth,mFrame.innerHeight];
  548.     }
  549.  
  550.     function GetCStyle(cmc) {
  551.         //IE,SM
  552.         //This functions completes the style of command with all the common
  553.         //parameters from the original style code.
  554.         //------------------------------
  555.         //Version 1.0
  556.         //
  557.         return "position: absolute; left:" + cmc.left + 
  558.                "; top: " + cmc.top + 
  559.                "; width: " + (OP?cmc.pixelWidth:cmc.width) + 
  560.                "; height: " + (OP?cmc.pixelHeight:cmc.height) + "; ";
  561.     }
  562.  
  563.     function SetUpEvents() {
  564.         //IE,NS
  565.         //This function initializes the frame variables and setups the event handling.
  566.         //------------------------------
  567.         //Version 1.0
  568.         //
  569.         error = errHandler;
  570.         if(typeof(mFrame)=="undefined")
  571.         //MENUFRAME
  572.         if(typeof(mFrame)=="undefined")
  573.             window.setTimeout("SetUpEvents()",10);
  574.         else {
  575.             if(NS) {
  576.                 mFrame.captureEvents(Event.MOUSEMOVE);
  577.                 mFrame.onmousemove = HideMenus;
  578.                 mFrame.window.captureEvents(Event.MOUSEDOWN);
  579.                 mFrame.window.onmousedown = ShowContextMenu;
  580.                 PrepareEvents();
  581.             }
  582.             if(IE) {
  583.                 document.onmousemove = HideMenus;
  584.                 mFrame.document.onmousemove = document.onmousemove;
  585.                 if(!SM) mFrame.document.oncontextmenu = ShowContextMenu;
  586.             }
  587.         }
  588.     }
  589.  
  590.     function errHandler(sMsg,sUrl,sLine) {
  591.         //E,NS
  592.         //his function will trap any errors generated by the scripts and filter the unhandled ones.
  593.         //-----------------------------
  594.         //ersion 1.0
  595.         //
  596.         if(sMsg.substr(0,16)!="Access is denied"&&sMsg!="Permission denied")
  597.             alert("DHTML Menu Builder Java Script Error\n" +
  598.                   "\nDescription: " + sMsg +
  599.                   "\nSource: " + sUrl +
  600.                   "\nLine: "+sLine);
  601.         return true;
  602.     }
  603.  
  604.     function PrepareEvents() {
  605.         //NS
  606.         //This function is called right after the menus are rendered.
  607.         //It has been designed to attach the OnClick event to the <layer> tag. This is being
  608.         //done this way because Navigator does not support inline event capturing on the
  609.         //click event in the layer tag... duh!
  610.         //------------------------------
  611.         //Version 2.0
  612.         //
  613.         for(var l=0; l<mFrame.document.layers.length; l++) {
  614.             var lo = mFrame.document.layers[l];
  615.             if(lo.layers.length) {
  616.                 lo.w = lo.clip.width;
  617.                 lo.h = lo.clip.height;
  618.                 for(var sl=0; sl<lo.layers[0].layers.length; sl++) {
  619.                     var slo = mFrame.document.layers[l].layers[0].layers[sl];
  620.                     if(slo.name.indexOf("EH")>0) {
  621.                         slo.document.onmouseup = hNSCClick;
  622.                         slo.document.TCode = nTCode[slo.name.split("EH")[1]];
  623.                     }                    
  624.                 }
  625.             }
  626.         }
  627.     }
  628.  
  629.     function ShowContextMenu(e) {
  630.         //IE,NS
  631.         //This function is called when a user rightclicks on the document and it will show a predefined menu.
  632.         //
  633.         //Just change the value of this variable to the name of the group
  634.         //you want to display when the user rightclicks on the document.
  635.         var MenuName = 'rightclick';
  636.         
  637.         if(IE)
  638.             if(!mFrame.document.all[MenuName])
  639.                 alert("The Context Menus AddIn is not correctly configured");
  640.             else {
  641.                 SetPointerPos();
  642.                 cFrame.ShowMenu(MenuName, mX, mY, false);
  643.                 return false;
  644.             }
  645.         
  646.         if(NS)
  647.             if(e.which==3)
  648.                 if(!mFrame.document.layers[MenuName])
  649.                     alert("The Context Menus AddIn is not correctly configured");
  650.                 else {
  651.                     cFrame.ShowMenu(MenuName, e.x, e.y, false);
  652.                     return false;
  653.                 }
  654.         
  655.         return true;
  656.     }
  657.  
  658. //BROWSERCODE
  659. //EXPAND
  660.  
  661.